﻿/*
wp_dlg.sqf
*/
#include "ACV_Constantes.h"
#include "ACV_ID_wp_dlg.h"

private ["_wp"];
disableSerialization;
_display = findDisplay ACV_DLG_ID_WP_Dlg;
_cb_wp = _display displayCtrl ACV_DLG_ID_WP_Type;
_cb_mode_combat = _display displayCtrl ACV_DLG_ID_WP_Combat;
_cb_formation = _display displayCtrl ACV_DLG_ID_WP_Formation;
_cb_speed = _display displayCtrl ACV_DLG_ID_WP_Vitesse;
_cb_behaviour = _display displayCtrl ACV_DLG_ID_WP_Comportement;
_ed_placement = _display displayCtrl ACV_DLG_ID_WP_Placement;
_ed_achevement = _display displayCtrl ACV_DLG_ID_WP_Achevement;
_ed_min = _display displayCtrl ACV_DLG_ID_WP_Min;
_ed_moy = _display displayCtrl ACV_DLG_ID_WP_Moy;
_ed_max = _display displayCtrl ACV_DLG_ID_WP_Max;
_ed_script = _display displayCtrl ACV_DLG_ID_WP_Script;
_ed_condition = _display displayCtrl ACV_DLG_ID_WP_Condition;

if((ACV_XXX==1) || (ACV_XXX==2)) then {
		_pos = ACV_Pos;
		_grp = ACV_Grp;
		
		_placement = abs parseNumber (ctrlText _ed_placement);
		_achevement = abs parseNumber (ctrlText _ed_achevement);
		_min = (abs parseNumber (ctrlText _ed_min) min 5000);
		_moy = (abs parseNumber (ctrlText _ed_moy) min 5000);
		_max = (abs parseNumber (ctrlText _ed_max) min 5000);

		if(ACV_XXX==1) then {
			_wp = _grp addWaypoint [_pos, _placement];
		}else{
			_wp = ACV_Wp;
			_wp setWaypointPosition [_pos, _placement];
		};
		_wp setWaypointCompletionRadius _achevement;
		_wp setWaypointType (_cb_wp lbdata (lbcursel _cb_wp));
		_wp setWaypointCombatMode (_cb_mode_combat lbdata (lbcursel _cb_mode_combat));
		_wp setWaypointFormation (_cb_formation lbdata (lbcursel _cb_formation));
		_wp setWaypointSpeed (_cb_speed lbdata (lbcursel _cb_speed));	
		_wp setWaypointBehaviour (_cb_behaviour lbdata (lbcursel _cb_behaviour));	
		_wp setWaypointTimeout [_min,_moy,_max];
		_wp setWaypointStatements [(ctrlText _ed_condition), (ctrlText _ed_script)];
		
};
closeDialog ACV_DLG_ID_WP_Dlg;